import 'package:dio/dio.dart';
import 'package:flutter/material.dart';

class ReqComment {
  final Dio _dio;

  ReqComment(this._dio);
  // 添加评论
  addComment({
    @required String content,
    @required int commentType,
    String userId,
    @required String objId,
  }) {
    return _dio.post('/comment/post', data: {
      "content": content,
      "comment_type": commentType,
      "comment_obj_user_id": userId,
      "comment_obj_id": objId,
    });
  }

  // 回复评论
  replayComment({
    @required String content,
    @required int commentType,
    @required String commentId,
    @required String objId,
  }) {
    return _dio.post('/comment/reply', data: {
      "content": content,
      "comment_type": commentType,
      "comment_id": commentId,
      "comment_obj_id": objId,
    });
  }

  //评论列表
  commentList({String commentId, int commentType}) {
    return _dio.get('/comment/list', queryParameters: {
      "comment_obj_id": commentId,
      "comment_type": commentType
    });
  }

  // 点赞
  givelike({
    @required String commentId,
  }) {
    return _dio.post('/comment/givelike', data: {"comment_id": commentId});
  }

  // 点赞
  downlike({
    @required String commentId,
  }) {
    return _dio.post('/comment/unlike', data: {"comment_id": commentId});
  }
}
